﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Devices.Geolocation;
using XingZhe.Common;
using XingZhe.Helpers;

namespace XingZhe.LocationListeners
{
        public class StatusChangeListener : IGeoStatusChanged
        {
                public void StatusChanged(Windows.Devices.Geolocation.Geolocator geolocator, Windows.Devices.Geolocation.StatusChangedEventArgs args)
                {
                        string statusMsg = string.Empty;
                        int? milliseconds = null;

                        switch (args.Status)
                        {
                                case PositionStatus.Disabled:
                                        // the application does not have the right capability or the location master switch is off
                                        // status = "location is disabled in phone settings";
                                        statusMsg = "位置服务已禁用";
                                        break;
                                case PositionStatus.Initializing:
                                        // the geolocator started the tracking operation
                                        // status = "initializing";
                                        statusMsg = "正在初始化...";
                                        break;
                                case PositionStatus.NoData:
                                        //  the location service was not able to acquire the location
                                        //  status = "no data";
                                        statusMsg = "暂时无法获取位置数据";
                                        break;
                                case PositionStatus.Ready:
                                        //  the location service is generating geopositions as specified by the tracking parameters
                                        //  status = "ready";
                                        statusMsg = "位置服务正在运行";
                                        milliseconds = 3000;
                                        break;
                                case PositionStatus.NotAvailable:
                                        // not used in WindowsPhone, Windows desktop uses this value to signal that there is no hardware capable to acquire location information
                                        statusMsg = "位置服务不可用";
                                        break;
                                case PositionStatus.NotInitialized:
                                        // the initial state of the geolocator, once the tracking operation is stopped by the user the geolocator moves back to this state
                                        statusMsg = "位置服务尚未初始化";
                                        break;
                        }

                        Debug.WriteLine(statusMsg);

                        XingZheHelper.SetBusyMessage(MessageTypeEnum.PositionStatusMsg, statusMsg, milliseconds);
                }
        }
}
